import { request } from "@/utils/service"
import type * as Order from "./types/order"
import { getToken } from "@/utils/cache/cookies"
import axios from "axios"
const baseURL = import.meta.env.VITE_BASE_API
/** 增 */
export function createOrderDataApi(data: Order.ICreateOrderRequestData, uid: any, isHj: any) {
  return request({
    url: isHj ? `order/addHeJi?uid=${uid}` : `order/add?uid=${uid}`,
    method: "post",
    data
  })
}
/** 删 */
// export function deleteOrderDataApi(id: string) {
//   return request({
//     url: "order/del",
//     method: "delete",
//     params: {
//       id
//     }
//   })
// }

/** 重提 */
export function updateOrderDataApi(data: Order.IUpdateOrderRequestData, t: Boolean) {
  return request({
    url: t ? "order/update" : "order/updateSubmit",
    method: "put",
    data
  })
}
/** 修改 */
export function update1OrderDataApi(data: Order.IUpdateOrderRequestData) {
  return request({
    url: "order/cover",
    method: "put",
    data
  })
}

/** 查 */
export function getOrderDataApi(params: Order.IGetOrderRequestData) {
  return request<Order.GetOrderResponseData>({
    url: "order/query",
    method: "get",
    params
  })
}

/**图片上传 */
export function uploadCidImageList(data: any) {
  return request({
    url: "order/image/upload",
    method: "post",
    headers: {
      "Content-Type": "multipart/form-data",
      token: getToken()
    },
    data
  })
}
export function getOrderOneApi(params: any) {
  return request<Order.GetOrderResponseData>({
    url: "order/detailed",
    method: "get",
    params
  })
}
/**下载 */
export function downLoadOrderTable(data: any) {
  return axios({
    url: `${baseURL}/order/downOrderList`,
    method: "post",
    headers: {
      "Content-Type": "multipart/form-data",
      token: getToken()
    },
    data,
    responseType: "blob"
  })
}
/**获取订单状态code */
export function getOrdeCode() {
  return request<Order.GetOrderResponseData>({
    url: "order/getAllState",
    method: "get"
  })
}
//  提现数据模块接口
/** 查 */
export function getOrderCenterDataApi(data: any) {
  return request({
    url: "withdrawals/queryPage",
    method: "post",
    headers: {
      "Content-Type": "multipart/form-data",
      token: getToken()
    },
    data
  })
}
// 获取提现数据状态
export function getCode(data: any) {
  return request({
    url: "withdrawals/getCode",
    method: "post",
    headers: {
      "Content-Type": "multipart/form-data",
      token: getToken()
    },
    data
  })
}
/** 修改 */
export function updategetOrderCenterApi(data: any) {
  return request({
    url: "withdrawals/submit",
    method: "post",
    data
  })
}
/**下载 */
export function updategetOrderCenterApiXZ(data: any) {
  return axios({
    url: `${baseURL}/withdrawals/downOrder`,
    method: "post",
    headers: {
      "Content-Type": "multipart/form-data",
      token: getToken()
    },
    data,
    responseType: "blob"
  })
}
// 推荐奖励查询
export function getOrderJlApi(params: any) {
  return request<any>({
    url: "/retail/reward/query",
    method: "get",
    params
  })
}
export function updateOrderJlApi(data: any) {
  return request({
    url: "/retail/reward/submit",
    method: "post",
    data
  })
}
// 下级订单 查
export function getconfigurationRuleApi(params: any) {
  return request<any>({
    // url: "/shop/retail/order/queryBelowOrder",
    url: "/shop/retail/order/queryBelowOrder2",
    method: "get",
    params
  })
}

// export function getconfigurationRuleApi(params: any) {
//   return request<any>({
//     url: "/order/queryBelow",
//     method: "get",
//     params
//   })
// }

// 下级订单的下级账号 查
export function getxjzhApi(params: any) {
  return request<any>({
    url: "/user/queryBelow",
    method: "get",
    params
  })
}
